<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .boxhome {
            width: 900px;
            height: 510px;
            background-color: #11212F;
            box-shadow: 0 0 8px black;
            cursor: pointer;
            position: relative;
            margin: auto;
            overflow: hidden;

        }

        .boxhome .pageimg {
            width: 2700px;
            position: absolute;
            left: 0;
            height: 340px;

            transition: 0.2s linear;

        }

        .pageimg>img {
            float: left;
        }

        .boxhome .pageimg img {
            width: 900px;
            height: 505px;

        }

        .left {
            width: 45px;
            height: 108px;
            background: rgba(0, 0, 0, 0.52);
            position: absolute;
            top: 35%;
            left: 0;
            cursor: pointer;
            border: none;
            z-index: 99;
            opacity: 0.5;
            border: none;
            display: none;
        }

        .left p {
            width: 23px;
            height: 36px;
            margin: 0 auto;
            margin-top: 35px;
            color: white;
            font-family: 宋体;
            font-size: 28px;

        }

        .left:hover {
            background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.8), transparent);
        }

        .right {
            width: 45px;
            height: 108px;
            background: rgba(0, 0, 0, 0.52);
            position: absolute;
            top: 35%;
            right: 0;
            cursor: pointer;
            display: none;
            z-index: 99;
            opacity: 0.5;
            border: none;
        }

        .right p {
            width: 23px;
            height: 36px;
            margin: 0 auto;
            margin-top: 35px;
            color: white;
            font-family: 宋体;
            font-size: 28px;

        }

        .right:hover {
            background-image: linear-gradient(-90deg, rgba(255, 255, 255, 0.8), transparent);
        }

        .boxhome .ul {

            transform: scale(1.5);
            position: absolute;
            bottom: 25px;
            left: 400px;
        }

        .ul li {
            width: 30px;
            height: 16px;
            background-color: #496274;
            float: left;
            margin-left: 5px;
            border-radius: 4px;
            cursor: pointer;
            color: transparent;

        }

        .ul li:hover {
            background-color: rgb(161, 181, 195);
        }
    </style>
</head>

<body>
    <div class="boxhome">
        <div class="pageimg">
            <img src="./img/t1.png" alt="">
            <img src="./img/t2.png" alt="">
            <img src="./img/t3.png" alt="">

        </div>
        <div class="left">
            <p>&lt;</p>
        </div>
        <div class="right">
            <p>></p>
        </div>
        <div class="ico">
            <ul>
                <li></li>
                <li></li>
                <li></li>
            </ul>
        </div>

    </div>
    <script>

        // 获取标签元素
        var lis = document.querySelector('.ico').querySelectorAll('li');
        var imgs = document.querySelector('.pageimg');
        var box = document.querySelector('.boxhome');
        var left = document.querySelector('.left');
        var right = document.querySelector('.right');
        // console.log(imgs);

        // 鼠标移到左右两个盒子按钮 消失显示
        box.addEventListener('mouseover', function () {
            left.style.display = 'block';
            right.style.display = 'block';
            left.style.backgroundColor = 'black';
            right.style.backgroundColor = 'black';
            clearInterval(time); // 鼠标移到盒子内 移出计时器
        });
        // 鼠标移到盒子外面两个按钮隐藏
        box.addEventListener('mouseleave', function () {
            left.style.display = 'none';
            right.style.display = 'none';
            time = setInterval(timer, 2000);
        })
        // 三个点 跳转相应位置
        for (let i = 0; i < lis.length; i++) {
            lis[i].onclick = function () {
                var x = 900 * i;
                imgs.style.transform = `translateX(${-x})px`// 添加2d位移
            }
            lis[i].addEventListener('click', function () {
                for (let k = 0; k < lis.length; k++) {
                    lis[k].style.backgroundColor = 'black';
                }
                lis[i].style.backgroundColor = '#A1B5C3';
                j = i;
            })
        }
        var j = 0;
        right.addEventListener('click',function(){
            j++; // 点击左边按钮
        })
    </script>
</body>

</html>